/*============================================================================*/
/*       UNIVERSIDAD DE GUADALAJARA - CONTINENTAL AUTOMOTIVE SYSTEMS          */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* %name:            intrpt_vectors %
* %version:         1.0 %
* %created_by:      %
* %date_created:    %
*=============================================================================*/
/* DESCRIPTION : Interrupts handling list                                     */
/*============================================================================*/
/* FUNCTION COMMENT : Provices Interrupts handlers                            */   
/*                                                                            */
/*                                                                            */
/*============================================================================*/

/* Includes */
/* -------- */
#include "stdtypedef.h"
#include "p18f4550.h"
#include "interrupts.h"
#include "hw_timers.h"
#include "intrpt_vectors.h"

/* Private functions prototypes */
/* ---------------------------- */
void low_isr(void);
void high_isr(void);

 /* 
 * For PIC18 devices the high interrupt vector is found at
 * 00000008h. The following code will branch to the
 * high_interrupt_service_routine function to handle
 * interrupts that occur at the high vector.
 */
#pragma code high_vector=0x08
void interrupt_at_high_vector(void)
{
  _asm GOTO high_isr _endasm
}
#pragma code /* return to the default code section */
/* 
 * For PIC18 devices the low interrupt vector is found at
 * 00000018h. The following code will branch to the
 * low_interrupt_service_routine function to handle
 * interrupts that occur at the low vector. 
 */
#pragma code low_vector=0x18
void interrupt_at_low_vector(void)
{
  _asm GOTO low_isr _endasm
}
#pragma code /* return to the default code section */


/* 
* ------------> Vectors 
*/

#pragma interruptlow low_isr
/**************************************************************
 *  Name                 :	low_isr
 *  Description          :	interrupt vector for low priority interrupts
 *  Parameters           :  none
 *  Return               :
 *  Critical/explanation :  No
 **************************************************************/
void low_isr (void)
{
  /* ... */
}

#pragma interrupt high_isr
/**************************************************************
 *  Name                 :	high_isr
 *  Description          :	interrupt vector for high priority interrupts
 *  Parameters           :  none
 *  Return               :
 *  Critical/explanation :  No
 **************************************************************/
void high_isr (void)
{
	if(INTCONbits.TMR0IF)
	{
		// Clear timer0 overflow flag
		INTCONbits.TMR0IF = 0;
		//Go to event manager
		timer0_Interrupt_Handler();
	}
}

/*
* ------------> Handlers
*/


